<!-- saved from url=(0026)/test.html -->
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <title>骡窝窝问答,问题解答</title>
    <meta name="viewport"
          content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no,minimal-ui,viewport-fit=cover">
    <meta name="format-detection" content="telephone=no,address=no">
    <link href="/css/mobile+css+head_mobile+css+ui^YVw^1526627473.css" rel="stylesheet" type="text/css">
    <link href="/css/new_ask2016.css" rel="stylesheet" type="text/css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/plugins/jquery-form/jquery.form.js"></script>
    <script src="/js/plugins/jrender/jrender.js"></script>
    <link rel="stylesheet" href="/js/plugins/dialog/dialog.css"/>
    <script src="/js/plugins/dialog/dialog.min.js"></script>
    <script src="/js/common.js"></script>


</head>
<body>
<div id="pos38"></div>
<header class="MfwHead ">
    <div class="LBtn"><a class="btn back"
                         href="javascript:void(window.history.length &gt; 1 ? window.history.back() : document.location.href=&#39;http://m.mafengwo.cn&#39;)"
                         id="_j_top_history_back"></a>
    </div>
    <div class="CBtn"><h1>问题解答</h1></div>
    <div class="RBtn">
    </div>
</header>

<div class="answer">
    <section class="ans-list a-list" render-loop="list">
        <ul class="_j_pager_box">

            <li>
                <a render-key="list.id" render-fun="handle">
                    <h2 render-html="list.title"></h2>
                </a>
                <div class="clearfix">
                    <div class="user-img clearfix" data-uid="46376914">
                        <p>
                            <img render-src="list.author.headImgUrl">
                        </p>
                        <span render-html="list.author.nickName"></span>
                        <span render-html="list.questionTime"></span>
                    </div>
                </div>
            </li>
        </ul>
    </section>
</div>
<div class="all">
    <div>
        <!--回答的内容回显-->
        <div class="answerContent">
            <div class="ans-list a-list" render-loop="list">
                <ul class="_j_pager_box">
                    <li>
                        <div class="clearfix">
                            <b><em>回答: </em></b>
                            <div class="user-img clearfix" data-uid="46376914">
                                <p>
                                    <img render-src="list.author.headImgUrl">
                                </p>
                                <span render-html="list.author.nickName"></span>
                                <span render-html="list.answerTime"></span>
                                <span render-html="list.answerContent"></span>
                            </div>
                            <div class="comment">
                                <form method="post" id="comment_operator" action="/communityComments">
                                    <div class="answer-box commentxxx">
                                        <input type="hidden" name="answerId">
                                        <input type="hidden" name="questionId">
                                        <div class="answer-box-right">
                                            <div class="nchtextarea">
                                                <i class="tip-icon tip-icon-left-sangle"></i>
                                                <span class="fl-l">
                                           <b><em>评论:</em></b>
                                        </span><br><br>
                                                <div render-loop="list.comments">
                                                    <div>
                                                        <div class="user-img clearfix" data-uid="46376914">
                                                        <img height="12px" render-src="list.comments.user.headImgUrl"></img>
                                                        </div>
                                                        <span render-html="list.comments.user.nickName"></span>
                                                        :
                                                        <span render-html="list.comments.commentContent"></span>
                                                    </div>
                                                </div>
                                                </div>
                                            </div>
                                            <br>
                                            <textarea class="ec-textarea" cols="55" rows="2" placeholder="点击添加您的评论"
                                                      name="commentContent">
                                          </textarea>
                                            <span class="tbmac-tip tbmac-tip-normal"></span>
                                        </div>
                                        <br>
                                        <button role="button" type="button" style="background-color: #cbcbcb"
                                                class="xxx" render-key="list.id" render-fun="idHandler"><i></i>
                                            提交评论
                                        </button>
                                    </div>
                                </form>
                                <!--评论 END-->
                            </div>
                        </div>
                    </li>
                </ul>

            </div>
        </div>
        <!--回答问题 START-->

        <div class="clearfianswer">
            <form method="post" id="answer_operator" action="/answers">
                <div class="answer-box clearfix" id="id">
                    <input type="hidden" name="questionId">
                    <div class="answer-box-right">
                        <div class="nchtextarea">
                            <i class="tip-icon tip-icon-left-sangle"></i>
                            <textarea class="ec-textarea" cols="60" rows="10" placeholder="点击添加您的回答"
                                      name="answerContent"></textarea> <span class="tbmac-tip tbmac-tip-normal"></span>
                        </div>
                        <div class="answer-submit">
                            <div class="answer-submit-btn">
                                <input type="hidden" name="answerToken" value="892282482E59AC1A91662DD75A77465F"
                                       class="tokenClass">
                                <input type="hidden" name="aid" value="">
                                <span class="answer-error" style="display: none;"><i
                                        class="tip-icon tip-icon-error"></i>请输入问题后在提交</span>
                                <br><br><br>
                                <a href="javascript:;" class="btn btn-orange answerBtn"><h2>提交回答</h2></a>
                            </div>
                        </div>
                    </div>
                </div>
            </form>

        </div>
    </div>
    <!--回答问题 END-->
    <div>
        <a href="mine/ask.html" class="btn-que"><i></i>
            我想要提问
        </a>
    </div>
</div>

</body>

<script>
    $(function () {
        //获取问题id
        var id = getParams().id;
        if (id) {
            $.get("/questions/" + id, function (data) {//ajax请求,渲染数据
                $(".answer").renderValues({list: data}, {
                    handle: function (ele, value) {
                        $(ele).attr("href", "/question.html?id=" + value);
                    }
                });
            });
        }
        $(".answerContent input[name='questionId']").val(id);
        //保存评论
        $(".answerContent").on("click", ".xxx", (function () {
            //把问题id设置到隐藏域再提交
            var id = $(this).data("id");
            //设置到表单隐藏表单控件
            $("#comment_operator input[name='answerId']").val(id);
            //把问题id设置到隐藏域再提交
            var currentForm = $(this).closest('form');
            currentForm.ajaxSubmit(function (data) {
                if (data.success) {
                    window.location.reload();
                }
            });
        }));


        $(".answerBtn").click(function () {
            //把问题id设置到隐藏域再提交
            $(".clearfix input[name='questionId']").val(id);
            //异步提交表单
            $("#answer_operator").ajaxSubmit(function (data) {
                if (data.success) {
                    window.location.reload();
                }
            });
        });

        //回答内容数据回显
        if (id) {
            $.get("/answers", {questionId: id}, function (data) {//ajax请求,渲染数据
                console.log(data);
                $(".all").renderValues({list: data}, {
                    handle: function (ele, value) {
                        /* $(ele).attr("href", "/question.html?id=" + value);*/
                    },
                    idHandler: function (ele, value) {
                        $(ele).attr("data-id", value);
                    }
                });
            });
        }
    });
</script>
</html>